﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>

<script type="text/javascript">

    $(function() {
        $("#txlgrouplist").change(groupselect);
    })

    //刷新
    function groupselect() {
        var txlgroup_id = $("#txlgrouplist").val();
        //alert($("#txlgrouplist").val());
        $("#txlgroup_id").val(txlgroup_id);
    }

    function TxlUpdate() {
        var txlgroup_id = $("#txlgroup_id").val();
        var txl_id = $("#txl_id").val();
        var txl_name = $("#txl_name").val();
        var txl_cellphone = $("#txl_cellphone").val();
        var txl_telephone = $("#txl_telephone").val();
        var txl_address = $("#txl_address").val();
        var txl_email = $("#txl_email").val();
        var txl_QQ = $("#txl_QQ").val();
        var txl_fax = $("#txl_fax").val();
        var txl_dept = $("#txl_dept").val();
        var txl_duty = $("#txl_duty").val();
        var txl_descn = $("#txl_descn").val();

        $.ajax({
            type: "POST",
            url: "/Txl/DoTxlUpdate",
            data: { "txl_id": txl_id, "txl_name": txl_name, "txl_cellphone": txl_cellphone, "txl_telephone": txl_telephone, "txl_address": txl_address,
                "txl_email": txl_email, "txl_QQ": txl_QQ, "txl_fax": txl_fax, "txl_dept": txl_dept, "txl_duty": txl_duty, "txl_descn": txl_descn, "txlgroup_id": txlgroup_id
            },
            success: function(restag) {
                if (restag.res != true) {
                    alert(restag.msg);
                }
                else {
                    alert("操作成功");
                    $.fn.deltab("3-5-3");
                    refreahtable();
                    addtab("3-5", "通讯录");
                }
            }
        });
    }

    function TxlAdd() {
        var txlgroup_id = $("#txlgroup_id").val();
        var txl_name = $("#txl_name").val();
        if (txlgroup_id == "") {
            alert("未选择小组");
            return;
        }
        if (txl_name == "") {
            alert("请填写名字");
            return;
        }
        var txl_cellphone = $("#txl_cellphone").val();
        var txl_telephone = $("#txl_telephone").val();
        var txl_address = $("#txl_address").val();
        var txl_email = $("#txl_email").val();
        var txl_QQ = $("#txl_QQ").val();
        var txl_fax = $("#txl_fax").val();
        var txl_dept = $("#txl_dept").val();
        var txl_duty = $("#txl_duty").val();
        var txl_descn = $("#txl_descn").val();

        $.ajax({
            type: "POST",
            url: "/Txl/DoTxlAdd",
            data: { "txlgroup_id": txlgroup_id, "txl_name": txl_name, "txl_cellphone": txl_cellphone, "txl_telephone": txl_telephone, "txl_address": txl_address,
                "txl_email": txl_email, "txl_QQ": txl_QQ, "txl_fax": txl_fax, "txl_dept": txl_dept, "txl_duty": txl_duty, "txl_descn": txl_descn
            },
            success: function(restag) {
                if (restag.res != true) {
                    alert(restag.msg);
                }
                else {
                    alert("操作成功");
                    $.fn.deltab('3-5-3');
                    $('#menu_selftxlmrg').trigger('click');
                }
            }
        });
    }
</script>

<div id="txlupdate" style="padding-left: 20px;">
    <div id="txlupdate_menu" style="height: 50px">
        <%if (ViewData["type"].ToString() == "update")
          { %>
        <input id="btn_txlupdate" type="button" class="btn_style" onclick="TxlUpdate()" value="保存修改"
            style="margin-right: 7px; margin-top: 5px;" /><!--增加右边界-->
        <%}
          else if (ViewData["type"].ToString() == "add")
          { %>
        <input id="btn_txladd" type="button" class="btn_style" onclick="TxlAdd()" value="添加组员"
            style="margin-right: 7px; margin-top: 5px;" /><!--增加右边界-->
        <%} %>
    </div>
    <div id="txlupdate_main">
        <%=Html.Hidden("txl_id",ViewData["txl_id"]) %>
        <%=Html.Hidden("txlgroup_id", ViewData["txlgroup_id"])%>
        <!--增加样式-->
        <span>小组：</span>
        <%=Html.DropDownList("txlgrouplist", ViewData["txlgrouplist"] as List<SelectListItem>, new { @style = "width: 250px; border: solid 1px #6C92AD;" })%>
        <br />
        <br />
        <span>姓名：</span>
        <%=Html.TextBox("txl_name",ViewData["txl_name"],new{@style="width: 250px; border: solid 1px #6C92AD;"}) %>
        <span style="margin-left: 80px;">手机：</span><!--修改左边界50_80-->
        <%=Html.TextBox("txl_cellphone", ViewData["txl_cellphone"], new { @style = "width: 250px; border: solid 1px #6C92AD;" })%>
        <br />
        <br />
        <span style="margin-right: 2px;">Q&nbsp;Q：</span>
        <%=Html.TextBox("txl_QQ", ViewData["txl_QQ"], new { @style = "width: 250px; border: solid 1px #6C92AD;" })%>
        <span style="margin-left: 53px;">固定电话：</span><!--修改左边界25_50-->
        <%=Html.TextBox("txl_telephone", ViewData["txl_telephone"], new { @style = "width: 250px; border: solid 1px #6C92AD;" })%>
        <br />
        <br />
        <span>职位：</span>
        <%=Html.TextBox("txl_duty", ViewData["txl_duty"], new { @style = "width: 250px; border: solid 1px #6C92AD;" })%>
        <span style="margin-left: 80px;">邮箱：</span><!--修改左边界50_80-->
        <%=Html.TextBox("txl_email", ViewData["txl_email"], new { @style = "width: 250px; border: solid 1px #6C92AD;" })%>
        <br />
        <br />
        <span>单位：</span>
        <%=Html.TextBox("txl_dept", ViewData["txl_dept"], new { @style = "width: 250px; border: solid 1px #6C92AD;" })%>
        <span style="margin-left: 80px;">传真：</span><!--修改左边界50_80-->
        <%=Html.TextBox("txl_fax", ViewData["txl_fax"], new { @style = "width: 250px; border: solid 1px #6C92AD;" })%>
        <br />
        <br />
        <span>地址：</span>
        <%=Html.TextBox("txl_address", ViewData["txl_address"], new { @style = "width: 250px; border: solid 1px #6C92AD;" })%>
        <br />
        <br />
        <span style="vertical-align: top;">备注：</span>
        <%=Html.TextArea("txl_descn", ViewData["txl_descn"].ToString(), new { @style = "height: 90px; width: 630px; max-width: 640px; border: solid 1px #6C92AD;" })%>
        <br />
        <br />
        <%if (ViewData["txl_img"] != null)
          { %>
        <span style="vertical-align: top;">头像：</span>
        <img alt="无" id="usersetting_img" width="100" height="100" src="<%=ViewData["txl_img"] %>" />
        <%} %>
    </div>
</div>
